package net.towee.server.bittorrent;

import java.io.InputStream;
import java.util.List;

import net.towee.model.bittorrent.TorrentData;
import net.towee.model.bittorrent.TorrentItem;

/**
 * This factory create a torrent data by given attachment id
 * 
 * @author c58
 */
public interface TorrentFactory {
	/**
	 * Create and register torrent in DB
	 * 
	 * @param torrent
	 * @param attId TODO
	 * @return true on success(if torrent with given infoHash not exists)
	 */
	TorrentData createTorrent(InputStream torrent, String attId);

	/**
	 * @return size of attached data in last created torrent
	 */
	long getContentSize();
	
	/**
	 * @return list of attached files of last created torrent
	 */
	List<TorrentItem> getItemsList();
	
	/**
	 * Parse torrent given from input stream, add announce url for
	 * logged in account, encode new torrent and stream it out.
	 * 
	 * @param accountId TODO
	 * @param stream with torrent
	 * @param output writer
	 */
	void processTorrent(String accountId, InputStream stream, Appendable out);
}
